//
//  gUCAmcJLCFListViewControllernRoqhZ.m
//  Dvjf_ios
//
//  Created by Ji on 2018/9/6.
//  Copyright © 2018年 ski. All rights reserved.
//

#import "gUCAmcJLCFListViewControllernRoqhZ.h"
#import "XvmSEfJLCFListRequestdkZIyb.h"
#import "uzZucYJLCFHomeBmapModelAwTcXU.h"
#import "wmCgpIJLCFListBmapCellkeSwUo.h"


@interface gUCAmcJLCFListViewControllernRoqhZ ()
{
    NSInteger _pageNumber;
}

@property (nonatomic, strong) NSMutableArray *QVdfMwbmapArrWKXWGt;

@end

@implementation gUCAmcJLCFListViewControllernRoqhZ

- (NSMutableArray *)QVdfMwbmapArrWKXWGt
{
    if (!_QVdfMwbmapArrWKXWGt) {
        _QVdfMwbmapArrWKXWGt = [NSMutableArray array];
    }
    return _QVdfMwbmapArrWKXWGt;
}

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    
    self.navigationBar.title = @"产品推荐";
    
    self.view.frame = CGRectMake(0, 0, FULL_WIDTH, FULL_HEIGHT - TABBAR_HEIGHT);
    self.tableView.frame = CGRectMake(0, NAVBAR_HEIGHT, FULL_WIDTH, self.view.height - NAVBAR_HEIGHT);
    self.tableView.backgroundColor = QTZ_Gray237;
    
    [self loadData];
    
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

- (void)loadData
{
    [self.QVdfMwbmapArrWKXWGt removeAllObjects];
    _pageNumber = 1;
    
    [XvmSEfJLCFListRequestdkZIyb postListDataWithParams:@{@"page" : @(_pageNumber) } loadingInView:self.tableView success:^(oOowQqJLCFListDataModeluDifDm *list) {
        
        [self hideNoMoreDataNotice];
        self.tableView.mj_footer.hidden = NO;
        [self.QVdfMwbmapArrWKXWGt addObjectsFromSafeArray:list.bmap];
        [self.tableView reloadData];
        [self endRefresh];
        
    } failure:^(NSString *error) {
        [self showNotice:error];
        [self endRefresh];
    }];
    
}

- (void)loadMoreData {
    
    [XvmSEfJLCFListRequestdkZIyb postListDataWithParams:@{@"page" : @(_pageNumber+1) } loadingInView:self.tableView success:^(oOowQqJLCFListDataModeluDifDm *list) {
        
        if (list.bmap.count > 0) {
            _pageNumber++;
            [self.QVdfMwbmapArrWKXWGt addObjectsFromSafeArray:list.bmap];
        } else {
            self.tableView.mj_footer.hidden = YES;
            [self showNoMoreDataNotice:@"没有更多了"];
        }
        [self.tableView reloadData];
        [self endLoadMore];
        
    } failure:^(NSString *error) {
        [self showNotice:error];
        [self endLoadMore];
    }];
    
}

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
    return self.QVdfMwbmapArrWKXWGt.count;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    return 1;
}

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
    return 165;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {

    wmCgpIJLCFListBmapCellkeSwUo *cell = [wmCgpIJLCFListBmapCellkeSwUo dequeueReusableCellForTableView:tableView];
    cell.aeeeWcbmapModelgTZMIY = [self.QVdfMwbmapArrWKXWGt safeObjectAtIndex:indexPath.section];
    [cell reloadData];
    return cell;

}

- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section {
    UIView *rRHNlxheaderViewfJQeRl = [[UIView alloc] initWithFrame:CGRectMake(0, 0, FULL_WIDTH, 10)];
    rRHNlxheaderViewfJQeRl.backgroundColor = [UIColor clearColor];
    return rRHNlxheaderViewfJQeRl;
}

- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section {
    return 10;
}

@end
